﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Domain.MainModule.Entities;
using Domain.Core.Specification;

namespace Domain.MainModule.Employees
{
    public class EmployeeBranchSpecification:Specification<Employee>
    {

        Guid _branchId;

        public EmployeeBranchSpecification(Guid branchId)
        {
            this._branchId = branchId;
        }

        public override System.Linq.Expressions.Expression<Func<Employee, bool>> SatisfiedBy()
        {
            Specification<Employee> spec = new TrueSpecification<Employee>();

            spec &= new DirectSpecification<Employee>(t => t.IsEnabled);

            spec &= new DirectSpecification<Employee>(c => c.BranchId.HasValue && c.BranchId.Value == this._branchId);

            return spec.SatisfiedBy();

        }
    }
}
